/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once


#include "基本类型.h"
#include "几何数据.h"

#include <vulkan/vulkan.h>
//#include "../Yi_GL.h"
//#include <d3d12.h>
#include "d3d12.h"



/*typedef enum {
	e_VBO = GL_ARRAY_BUFFER,
	e_UBO = GL_UNIFORM_BUFFER,
	e_TBO = GL_TEXTURE_BUFFER,
	e_SSBO = GL_SHADER_STORAGE_BUFFER,
	e_INDEX = GL_ELEMENT_ARRAY_BUFFER,
	e_INDIRECT = GL_DRAW_INDIRECT_BUFFER,
	e_AIOMIC = GL_ATOMIC_COUNTER_BUFFER,
	e_DI = GL_DISPATCH_INDIRECT_BUFFER,

	e_UBO_VK = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
	e_VBO_VK = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,

	e_Layout_VBO_VK = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
	e_Layout_IMAGE_VK = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,

	e_DX_内存堆_DEFAULT = D3D12_HEAP_TYPE_DEFAULT,
	e_DX_内存堆_UPLOAD = D3D12_HEAP_TYPE_UPLOAD,

}E_GPU缓存类型;*/



typedef struct {
	const void*	data;
	uint32	length;
	uint32	byteOffset;

}S_GPU缓存创建参数;



typedef struct {
	void*	BufferLocation;
	uint32	SizeInBytes;
	uint32	间隔InBytes;
}S_GUP内存映射;







/*inline uint32 f_内存类型索引(VkPhysicalDeviceMemoryProperties& info, uint32_t typeBits, VkFlags requirements_mask) {
	for (uint32 i = 0; i < info.memoryTypeCount; i++) {
		if ((typeBits & 1) == 1) {
			// Type is available, does it match user properties?
			if ((info.memoryTypes[i].propertyFlags & requirements_mask) == requirements_mask) {
				return i;
			}
		}
		typeBits >>= 1;
	}
	// No memory types matched, return failure
	return 0xffffffff;
}*/







struct S_GPU缓存 {
	uint32			m_Count;
	uint16			m_BitOffset;
	//uint8			m_Bit;
	void*			m_Buf;

	S_GPU缓存(){}


	virtual uint32	f_创建内存对象(const void* c, void* ctx = 0, uint32 key = 0) = 0;
	virtual void	f_Fill(const void* data, uint64 size, void* ctx) = 0;
	//virtual void	f_Fill(uint32 key, uint64 size, void* data) = 0;
	virtual S_GUP内存映射	f_map() = 0;
	virtual void			f_unmap() = 0;

	
};




struct S_GPU缓存_D3 {
	uint64			m_BitSize;
	uint32			m_Count;
	uint8			m_Bit;
	void*			m_Buf;

	S_GPU缓存_D3() {}


	virtual uint32	f_创建内存对象(const void* t, void* ctx = 0, uint32 key=0) = 0;
	virtual void	f_Fill(void* data, int3_64 size, void* ctx) = 0;
	//virtual void	f_Fill(uint32 key, uint64 size, void* data) = 0;
	virtual void*	f_map() = 0;
	virtual void	f_unmap() = 0;


};




